<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>pypln.apps.extractor</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/pypln">Project Homepage</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;pypln ::
        <a href="pypln.apps-module.html">Package&nbsp;apps</a> ::
        Module&nbsp;extractor
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="pypln.apps.extractor-module.html">Module pypln.apps.extractor</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-comment">#!/usr/bin/env python</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-comment">#-*- coding:utf-8 -*-</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-docstring">New Document processor</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-docstring">This app scans a directory and submits new/changed documents to the </tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-docstring">preprocessing pipeline</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-docstring">Which will perform, in order:</tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-docstring">* mimetype detection</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-docstring">* encoding detection</tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-docstring">* text extraction and conversion if necessary</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-docstring">* Storage of extracted text in database</tt> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-name">__docformat__</tt> <tt class="py-op">=</tt> <tt class="py-string">"restructuredtext en"</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">os</tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">sys</tt><tt class="py-op">,</tt><tt class="py-name">argparse</tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">collections</tt> <tt class="py-keyword">import</tt> <tt class="py-name">defaultdict</tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">mimetypes</tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">multiprocessing</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Process</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">subprocess</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Popen</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Package pypln.pypln=pypln.pypln-module.html"><a title="pypln.pypln" class="py-name" href="#" onclick="return doclink('link-0', 'pypln', 'link-0');">pypln</a></tt><tt class="py-op">.</tt><tt id="link-1" class="py-name" targets="Package pypln.pypln.servers=pypln.pypln.servers-module.html"><a title="pypln.pypln.servers" class="py-name" href="#" onclick="return doclink('link-1', 'servers', 'link-1');">servers</a></tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Module pypln.pypln.servers.ventilator=pypln.pypln.servers.ventilator-module.html"><a title="pypln.pypln.servers.ventilator" class="py-name" href="#" onclick="return doclink('link-2', 'ventilator', 'link-2');">ventilator</a></tt> <tt class="py-keyword">import</tt> <tt id="link-3" class="py-name" targets="Class pypln.pypln.servers.ventilator.Ventilator=pypln.pypln.servers.ventilator.Ventilator-class.html"><a title="pypln.pypln.servers.ventilator.Ventilator" class="py-name" href="#" onclick="return doclink('link-3', 'Ventilator', 'link-3');">Ventilator</a></tt> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-4" class="py-name"><a title="pypln.pypln" class="py-name" href="#" onclick="return doclink('link-4', 'pypln', 'link-0');">pypln</a></tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Package pypln.pypln.stores=pypln.pypln.stores-module.html"><a title="pypln.pypln.stores" class="py-name" href="#" onclick="return doclink('link-5', 'stores', 'link-5');">stores</a></tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Module pypln.pypln.stores.filestor=pypln.pypln.stores.filestor-module.html"><a title="pypln.pypln.stores.filestor" class="py-name" href="#" onclick="return doclink('link-6', 'filestor', 'link-6');">filestor</a></tt> <tt class="py-keyword">import</tt> <tt id="link-7" class="py-name" targets="Class pypln.pypln.stores.filestor.FS=pypln.pypln.stores.filestor.FS-class.html"><a title="pypln.pypln.stores.filestor.FS" class="py-name" href="#" onclick="return doclink('link-7', 'FS', 'link-7');">FS</a></tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-8" class="py-name"><a title="pypln.pypln" class="py-name" href="#" onclick="return doclink('link-8', 'pypln', 'link-0');">pypln</a></tt><tt class="py-op">.</tt><tt id="link-9" class="py-name" targets="Package pypln.pypln.workers=pypln.pypln.workers-module.html"><a title="pypln.pypln.workers" class="py-name" href="#" onclick="return doclink('link-9', 'workers', 'link-9');">workers</a></tt><tt class="py-op">.</tt><tt id="link-10" class="py-name" targets="Module pypln.pypln.workers.pdfconv_worker=pypln.pypln.workers.pdfconv_worker-module.html"><a title="pypln.pypln.workers.pdfconv_worker" class="py-name" href="#" onclick="return doclink('link-10', 'pdfconv_worker', 'link-10');">pdfconv_worker</a></tt> <tt class="py-keyword">import</tt> <tt id="link-11" class="py-name" targets="Class pypln.pypln.workers.pdfconv_worker.PDFConverterWorker=pypln.pypln.workers.pdfconv_worker.PDFConverterWorker-class.html"><a title="pypln.pypln.workers.pdfconv_worker.PDFConverterWorker" class="py-name" href="#" onclick="return doclink('link-11', 'PDFConverterWorker', 'link-11');">PDFConverterWorker</a></tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-12" class="py-name"><a title="pypln.pypln" class="py-name" href="#" onclick="return doclink('link-12', 'pypln', 'link-0');">pypln</a></tt><tt class="py-op">.</tt><tt id="link-13" class="py-name" targets="Package pypln.pypln.sinks=pypln.pypln.sinks-module.html"><a title="pypln.pypln.sinks" class="py-name" href="#" onclick="return doclink('link-13', 'sinks', 'link-13');">sinks</a></tt><tt class="py-op">.</tt><tt id="link-14" class="py-name" targets="Module pypln.pypln.sinks.mongo_insert_sink=pypln.pypln.sinks.mongo_insert_sink-module.html"><a title="pypln.pypln.sinks.mongo_insert_sink" class="py-name" href="#" onclick="return doclink('link-14', 'mongo_insert_sink', 'link-14');">mongo_insert_sink</a></tt> <tt class="py-keyword">import</tt> <tt id="link-15" class="py-name" targets="Class pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink=pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink-class.html"><a title="pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink" class="py-name" href="#" onclick="return doclink('link-15', 'MongoInsertSink', 'link-15');">MongoInsertSink</a></tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">pymongo</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Connection</tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-16" class="py-name"><a title="pypln.pypln" class="py-name" href="#" onclick="return doclink('link-16', 'pypln', 'link-0');">pypln</a></tt><tt class="py-op">.</tt><tt id="link-17" class="py-name"><a title="pypln.pypln.workers" class="py-name" href="#" onclick="return doclink('link-17', 'workers', 'link-9');">workers</a></tt><tt class="py-op">.</tt><tt id="link-18" class="py-name"><a title="pypln.pypln.workers.pdfconv_worker" class="py-name" href="#" onclick="return doclink('link-18', 'pdfconv_worker', 'link-10');">pdfconv_worker</a></tt> <tt class="py-keyword">import</tt> <tt id="link-19" class="py-name"><a title="pypln.pypln.workers.pdfconv_worker.PDFConverterWorker" class="py-name" href="#" onclick="return doclink('link-19', 'PDFConverterWorker', 'link-11');">PDFConverterWorker</a></tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">time</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"> </tt>
<a name="scan_dir"></a><div id="scan_dir-def"><a name="L30"></a><tt class="py-lineno"> 30</tt> <a class="py-toggle" href="#" id="scan_dir-toggle" onclick="return toggle('scan_dir');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.apps.extractor-module.html#scan_dir">scan_dir</a><tt class="py-op">(</tt><tt class="py-param">path</tt><tt class="py-op">,</tt> <tt class="py-param">db</tt><tt class="py-op">,</tt> <tt class="py-param">recurse</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="scan_dir-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="scan_dir-expanded"><a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"><tt class="py-docstring">    Scans a directory, adds files to the GridFS and returns</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"><tt class="py-docstring">    dictionary of files by mimetype</tt> </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line">    <tt class="py-name">fs</tt> <tt class="py-op">=</tt> <tt id="link-20" class="py-name"><a title="pypln.pypln.stores.filestor.FS" class="py-name" href="#" onclick="return doclink('link-20', 'FS', 'link-7');">FS</a></tt><tt class="py-op">(</tt><tt class="py-name">db</tt><tt class="py-op">,</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">    <tt class="py-name">docdict</tt> <tt class="py-op">=</tt> <tt class="py-name">defaultdict</tt><tt class="py-op">(</tt><tt class="py-keyword">lambda</tt><tt class="py-op">:</tt><tt class="py-op">[</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">p</tt><tt class="py-op">,</tt> <tt class="py-name">dirs</tt><tt class="py-op">,</tt> <tt class="py-name">files</tt> <tt class="py-keyword">in</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">walk</tt><tt class="py-op">(</tt><tt class="py-name">path</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">recurse</tt><tt class="py-op">:</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line">            <tt class="py-name">dirs</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">f</tt> <tt class="py-keyword">in</tt> <tt class="py-name">files</tt><tt class="py-op">:</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line">            <tt class="py-name">mt</tt> <tt class="py-op">=</tt> <tt class="py-name">mimetypes</tt><tt class="py-op">.</tt><tt class="py-name">guess_type</tt><tt class="py-op">(</tt><tt class="py-name">f</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line">            <tt class="py-comment">#classify documents by mimetype</tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line">            <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line">                <tt class="py-name">fullpath</tt> <tt class="py-op">=</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">path</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">getcwd</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">path</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-name">p</tt><tt class="py-op">,</tt> <tt class="py-name">f</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">decode</tt><tt class="py-op">(</tt><tt class="py-string">'utf8'</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line">            <tt class="py-keyword">except</tt> <tt class="py-name">UnicodeDecodeError</tt><tt class="py-op">:</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">                <tt class="py-keyword">print</tt> <tt class="py-string">"skipping: "</tt><tt class="py-op">,</tt><tt class="py-name">f</tt> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">                <tt class="py-keyword">continue</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">            <tt class="py-name">fid</tt> <tt class="py-op">=</tt> <tt class="py-name">fs</tt><tt class="py-op">.</tt><tt id="link-21" class="py-name" targets="Method pypln.pypln.stores.filestor.FS.add_file()=pypln.pypln.stores.filestor.FS-class.html#add_file"><a title="pypln.pypln.stores.filestor.FS.add_file" class="py-name" href="#" onclick="return doclink('link-21', 'add_file', 'link-21');">add_file</a></tt><tt class="py-op">(</tt><tt class="py-name">fullpath</tt><tt class="py-op">)</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">fid</tt> <tt class="py-op">!=</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">                <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt class="py-name">fs</tt><tt class="py-op">.</tt><tt class="py-name">fs</tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-name">fid</tt><tt class="py-op">)</tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">                <tt class="py-name">docdict</tt><tt class="py-op">[</tt><tt class="py-name">mt</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">md5</tt><tt class="py-op">)</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">docdict</tt> </tt>
</div><a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line"> </tt>
<a name="scan_gridfs"></a><div id="scan_gridfs-def"><a name="L54"></a><tt class="py-lineno"> 54</tt> <a class="py-toggle" href="#" id="scan_gridfs-toggle" onclick="return toggle('scan_gridfs');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.apps.extractor-module.html#scan_gridfs">scan_gridfs</a><tt class="py-op">(</tt><tt class="py-param">db</tt><tt class="py-op">,</tt><tt class="py-param">host</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="scan_gridfs-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="scan_gridfs-expanded"><a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line"><tt class="py-docstring">    scans gridfs under a given database and returns</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line"><tt class="py-docstring">    a dictionary of files by mimetype</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">    <tt class="py-comment">#TODO: maybe it's better to identify files by ID in both these scan functions.</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line">    <tt class="py-name">docdict</tt> <tt class="py-op">=</tt> <tt class="py-name">defaultdict</tt><tt class="py-op">(</tt><tt class="py-keyword">lambda</tt><tt class="py-op">:</tt><tt class="py-op">[</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line">    <tt class="py-name">files</tt> <tt class="py-op">=</tt> <tt class="py-name">Connection</tt><tt class="py-op">(</tt><tt class="py-string">'127.0.0.1'</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-name">db</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">fs</tt><tt class="py-op">.</tt><tt class="py-name">files</tt> </tt>
<a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">    <tt class="py-name">fs</tt> <tt class="py-op">=</tt> <tt id="link-22" class="py-name"><a title="pypln.pypln.stores.filestor.FS" class="py-name" href="#" onclick="return doclink('link-22', 'FS', 'link-7');">FS</a></tt><tt class="py-op">(</tt><tt class="py-name">db</tt><tt class="py-op">,</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">    <tt class="py-name">cursor</tt> <tt class="py-op">=</tt> <tt class="py-name">files</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">f</tt> <tt class="py-keyword">in</tt> <tt class="py-name">cursor</tt><tt class="py-op">:</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">        <tt class="py-name">mt</tt> <tt class="py-op">=</tt> <tt class="py-name">mimetypes</tt><tt class="py-op">.</tt><tt class="py-name">guess_type</tt><tt class="py-op">(</tt><tt class="py-name">f</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-string">'filename'</tt><tt class="py-op">]</tt><tt class="py-comment">#classify documents by mimetype</tt> </tt>
<a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">        <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt class="py-name">fs</tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-name">f</tt><tt class="py-op">[</tt><tt class="py-string">'_id'</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line">        <tt class="py-name">docdict</tt><tt class="py-op">[</tt><tt class="py-name">mt</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">.</tt><tt class="py-name">md5</tt><tt class="py-op">)</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">docdict</tt> </tt>
</div><a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line">     </tt>
<a name="setup_workers"></a><div id="setup_workers-def"><a name="L70"></a><tt class="py-lineno"> 70</tt> <a class="py-toggle" href="#" id="setup_workers-toggle" onclick="return toggle('setup_workers');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.apps.extractor-module.html#setup_workers">setup_workers</a><tt class="py-op">(</tt><tt class="py-param">nw</tt><tt class="py-op">=</tt><tt class="py-number">5</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="setup_workers-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="setup_workers-expanded"><a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line"><tt class="py-docstring">    Start the worker processes</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">    <tt class="py-name">WP</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">Process</tt><tt class="py-op">(</tt><tt class="py-name">target</tt><tt class="py-op">=</tt><tt id="link-23" class="py-name"><a title="pypln.pypln.workers.pdfconv_worker.PDFConverterWorker" class="py-name" href="#" onclick="return doclink('link-23', 'PDFConverterWorker', 'link-11');">PDFConverterWorker</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> <tt class="py-keyword">for</tt> <tt class="py-name">i</tt> <tt class="py-keyword">in</tt> <tt class="py-name">range</tt><tt class="py-op">(</tt><tt class="py-name">nw</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">    <tt class="py-op">[</tt><tt class="py-name">p</tt><tt class="py-op">.</tt><tt id="link-24" class="py-name" targets="Method pypln.pypln.sinks.base.BaseSink.start()=pypln.pypln.sinks.base.BaseSink-class.html#start,Method pypln.pypln.sinks.dummy_sink.DummySink.start()=pypln.pypln.sinks.dummy_sink.DummySink-class.html#start,Method pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.start()=pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink-class.html#start,Method pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.start()=pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink-class.html#start,Method pypln.pypln.sinks.raw_document_sink.RawDocumentSink.start()=pypln.pypln.sinks.raw_document_sink.RawDocumentSink-class.html#start,Method pypln.pypln.workers.base.BaseWorker.start()=pypln.pypln.workers.base.BaseWorker-class.html#start,Method pypln.pypln.workers.base.PushPullWorker.start()=pypln.pypln.workers.base.PushPullWorker-class.html#start,Method pypln.pypln.workers.dummy_worker.DummyWorker.start()=pypln.pypln.workers.dummy_worker.DummyWorker-class.html#start,Method pypln.pypln.workers.enc_detect_worker.EncodingWorker.start()=pypln.pypln.workers.enc_detect_worker.EncodingWorker-class.html#start,Method pypln.pypln.workers.mime_detect_worker.MimeWorker.start()=pypln.pypln.workers.mime_detect_worker.MimeWorker-class.html#start,Method pypln.pypln.workers.palavras_worker.Palavras_worker.start()=pypln.pypln.workers.palavras_worker.Palavras_worker-class.html#start,Method pypln.pypln.workers.parser_worker.ParserWorker.start()=pypln.pypln.workers.parser_worker.ParserWorker-class.html#start"><a title="pypln.pypln.sinks.base.BaseSink.start
pypln.pypln.sinks.dummy_sink.DummySink.start
pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.start
pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.start
pypln.pypln.sinks.raw_document_sink.RawDocumentSink.start
pypln.pypln.workers.base.BaseWorker.start
pypln.pypln.workers.base.PushPullWorker.start
pypln.pypln.workers.dummy_worker.DummyWorker.start
pypln.pypln.workers.enc_detect_worker.EncodingWorker.start
pypln.pypln.workers.mime_detect_worker.MimeWorker.start
pypln.pypln.workers.palavras_worker.Palavras_worker.start
pypln.pypln.workers.parser_worker.ParserWorker.start" class="py-name" href="#" onclick="return doclink('link-24', 'start', 'link-24');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-keyword">for</tt> <tt class="py-name">p</tt> <tt class="py-keyword">in</tt> <tt class="py-name">WP</tt><tt class="py-op">]</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">    <tt class="py-comment">#WP = [Popen(['python', '../pypln/workers/pdfconv_worker.py'], stdout=None) for i in range(nw)]</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">WP</tt> </tt>
</div><a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line">     </tt>
<a name="setup_sink"></a><div id="setup_sink-def"><a name="L79"></a><tt class="py-lineno"> 79</tt> <a class="py-toggle" href="#" id="setup_sink-toggle" onclick="return toggle('setup_sink');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.apps.extractor-module.html#setup_sink">setup_sink</a><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="setup_sink-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="setup_sink-expanded"><a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line"><tt class="py-docstring">    Start ns sink process(es)</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">    <tt class="py-name">SP</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">Process</tt><tt class="py-op">(</tt><tt class="py-name">target</tt><tt class="py-op">=</tt><tt id="link-25" class="py-name"><a title="pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink" class="py-name" href="#" onclick="return doclink('link-25', 'MongoInsertSink', 'link-15');">MongoInsertSink</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line">    <tt class="py-name">SP</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-26" class="py-name"><a title="pypln.pypln.sinks.base.BaseSink.start
pypln.pypln.sinks.dummy_sink.DummySink.start
pypln.pypln.sinks.mongo_insert_sink.MongoInsertSink.start
pypln.pypln.sinks.mongo_update_sink.MongoUpdateSink.start
pypln.pypln.sinks.raw_document_sink.RawDocumentSink.start
pypln.pypln.workers.base.BaseWorker.start
pypln.pypln.workers.base.PushPullWorker.start
pypln.pypln.workers.dummy_worker.DummyWorker.start
pypln.pypln.workers.enc_detect_worker.EncodingWorker.start
pypln.pypln.workers.mime_detect_worker.MimeWorker.start
pypln.pypln.workers.palavras_worker.Palavras_worker.start
pypln.pypln.workers.parser_worker.ParserWorker.start" class="py-name" href="#" onclick="return doclink('link-26', 'start', 'link-24');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line">    <tt class="py-comment">#SP = [Popen(['python', '../pypln/sinks/mongo_insert_sink.py'], stdout=None)]</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">SP</tt> </tt>
</div><a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line"> </tt>
<a name="extract"></a><div id="extract-def"><a name="L88"></a><tt class="py-lineno"> 88</tt> <a class="py-toggle" href="#" id="extract-toggle" onclick="return toggle('extract');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.apps.extractor-module.html#extract">extract</a><tt class="py-op">(</tt><tt class="py-param">path</tt><tt class="py-op">,</tt><tt class="py-param">nw</tt><tt class="py-op">=</tt><tt class="py-number">10</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="extract-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="extract-expanded"><a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">    <tt class="py-comment">#TODO: Currently broken. Implement a generic text extractor worker which is mimetype aware</tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">    <tt class="py-name">pdf_ext_vent</tt> <tt class="py-op">=</tt> <tt id="link-27" class="py-name"><a title="pypln.pypln.servers.ventilator.Ventilator" class="py-name" href="#" onclick="return doclink('link-27', 'Ventilator', 'link-3');">Ventilator</a></tt><tt class="py-op">(</tt><tt class="py-name">pushport</tt><tt class="py-op">=</tt><tt class="py-number">5557</tt><tt class="py-op">,</tt> <tt class="py-name">pubport</tt><tt class="py-op">=</tt><tt class="py-number">5559</tt><tt class="py-op">,</tt> <tt class="py-name">subport</tt><tt class="py-op">=</tt><tt class="py-number">5560</tt><tt class="py-op">)</tt> </tt>
<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">    <tt class="py-name">time</tt><tt class="py-op">.</tt><tt class="py-name">sleep</tt><tt class="py-op">(</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">    <tt class="py-name">docs</tt> <tt class="py-op">=</tt> <tt id="link-28" class="py-name" targets="Function pypln.apps.extractor.scan_dir()=pypln.apps.extractor-module.html#scan_dir"><a title="pypln.apps.extractor.scan_dir" class="py-name" href="#" onclick="return doclink('link-28', 'scan_dir', 'link-28');">scan_dir</a></tt><tt class="py-op">(</tt><tt class="py-name">path</tt><tt class="py-op">,</tt> <tt class="py-name">args</tt><tt class="py-op">.</tt><tt class="py-name">db</tt><tt class="py-op">)</tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-string">"number of PDFs "</tt><tt class="py-op">,</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">docs</tt><tt class="py-op">[</tt><tt class="py-string">'application/pdf'</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">    <tt class="py-name">msgs</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">v</tt> <tt class="py-keyword">in</tt> <tt class="py-name">docs</tt><tt class="py-op">[</tt><tt class="py-string">'application/pdf'</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line">        <tt class="py-name">msgs</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt class="py-op">{</tt><tt class="py-string">'database'</tt><tt class="py-op">:</tt><tt class="py-name">args</tt><tt class="py-op">.</tt><tt class="py-name">db</tt><tt class="py-op">,</tt><tt class="py-string">'collection'</tt><tt class="py-op">:</tt><tt class="py-name">args</tt><tt class="py-op">.</tt><tt class="py-name">col</tt><tt class="py-op">,</tt><tt class="py-string">'md5'</tt><tt class="py-op">:</tt><tt class="py-name">v</tt><tt class="py-op">}</tt><tt class="py-op">)</tt> </tt>
<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line">    <tt class="py-name">pdf_ext_vent</tt><tt class="py-op">.</tt><tt id="link-29" class="py-name" targets="Method pypln.pypln.servers.ventilator.Ventilator.push_load()=pypln.pypln.servers.ventilator.Ventilator-class.html#push_load"><a title="pypln.pypln.servers.ventilator.Ventilator.push_load" class="py-name" href="#" onclick="return doclink('link-29', 'push_load', 'link-29');">push_load</a></tt><tt class="py-op">(</tt><tt class="py-name">msgs</tt><tt class="py-op">)</tt> </tt>
</div><a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line"> </tt>
<a name="directory"></a><div id="directory-def"><a name="L99"></a><tt class="py-lineno"> 99</tt> <a class="py-toggle" href="#" id="directory-toggle" onclick="return toggle('directory');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pypln.apps.extractor-module.html#directory">directory</a><tt class="py-op">(</tt><tt class="py-param">d</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="directory-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="directory-expanded"><a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line"><tt class="py-docstring">    checks if path is a directory</tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">os</tt><tt class="py-op">.</tt><tt class="py-name">path</tt><tt class="py-op">.</tt><tt class="py-name">isdir</tt><tt class="py-op">(</tt><tt class="py-name">d</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">        <tt class="py-keyword">pass</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">        <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">"%s is not a directory"</tt> <tt class="py-op">%</tt> <tt class="py-name">d</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">argparse</tt><tt class="py-op">.</tt><tt class="py-name">ArgumentTypeError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">d</tt> </tt>
</div><a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">             </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line"><tt class="py-keyword">if</tt> <tt class="py-name">__name__</tt><tt class="py-op">==</tt><tt class="py-string">"__main__"</tt><tt class="py-op">:</tt> </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">    <tt id="link-30" class="py-name" targets="Module pypln.apps.parser=pypln.apps.parser-module.html"><a title="pypln.apps.parser" class="py-name" href="#" onclick="return doclink('link-30', 'parser', 'link-30');">parser</a></tt> <tt class="py-op">=</tt> <tt class="py-name">argparse</tt><tt class="py-op">.</tt><tt class="py-name">ArgumentParser</tt><tt class="py-op">(</tt><tt class="py-name">description</tt><tt class="py-op">=</tt><tt class="py-string">'Scans a directory tree or gridfs distributed file system looking for files to convert to text'</tt><tt class="py-op">)</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">    <tt class="py-comment">#group = parser.add_mutually_exclusive_group(required=True)</tt> </tt>
<a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">    <tt id="link-31" class="py-name"><a title="pypln.apps.parser" class="py-name" href="#" onclick="return doclink('link-31', 'parser', 'link-30');">parser</a></tt><tt class="py-op">.</tt><tt class="py-name">add_argument</tt><tt class="py-op">(</tt><tt class="py-string">'-H'</tt><tt class="py-op">,</tt> <tt class="py-string">'--host'</tt><tt class="py-op">,</tt> <tt class="py-name">default</tt><tt class="py-op">=</tt><tt class="py-string">'127.0.0.1'</tt><tt class="py-op">,</tt> <tt class="py-name">help</tt><tt class="py-op">=</tt><tt class="py-string">'Host ip of the MongoDB server.'</tt><tt class="py-op">)</tt> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">    <tt id="link-32" class="py-name"><a title="pypln.apps.parser" class="py-name" href="#" onclick="return doclink('link-32', 'parser', 'link-30');">parser</a></tt><tt class="py-op">.</tt><tt class="py-name">add_argument</tt><tt class="py-op">(</tt><tt class="py-string">'-d'</tt><tt class="py-op">,</tt> <tt class="py-string">'--db'</tt><tt class="py-op">,</tt> <tt class="py-name">required</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">,</tt> <tt class="py-name">help</tt><tt class="py-op">=</tt><tt class="py-string">"Database in which to deposit the texts"</tt><tt class="py-op">)</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">    <tt id="link-33" class="py-name"><a title="pypln.apps.parser" class="py-name" href="#" onclick="return doclink('link-33', 'parser', 'link-30');">parser</a></tt><tt class="py-op">.</tt><tt class="py-name">add_argument</tt><tt class="py-op">(</tt><tt class="py-string">'-c'</tt><tt class="py-op">,</tt> <tt class="py-string">'--col'</tt><tt class="py-op">,</tt> <tt class="py-name">required</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">,</tt> <tt class="py-name">help</tt><tt class="py-op">=</tt><tt class="py-string">"Collection in which to deposit the texts"</tt><tt class="py-op">)</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">    <tt id="link-34" class="py-name"><a title="pypln.apps.parser" class="py-name" href="#" onclick="return doclink('link-34', 'parser', 'link-30');">parser</a></tt><tt class="py-op">.</tt><tt class="py-name">add_argument</tt><tt class="py-op">(</tt><tt class="py-string">'-g'</tt><tt class="py-op">,</tt><tt class="py-string">'--gfs'</tt><tt class="py-op">,</tt> <tt class="py-name">help</tt><tt class="py-op">=</tt><tt class="py-string">" Scan griGridFS under db. Overrides path"</tt><tt class="py-op">)</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">    <tt id="link-35" class="py-name"><a title="pypln.apps.parser" class="py-name" href="#" onclick="return doclink('link-35', 'parser', 'link-30');">parser</a></tt><tt class="py-op">.</tt><tt class="py-name">add_argument</tt><tt class="py-op">(</tt> <tt class="py-string">'path'</tt><tt class="py-op">,</tt> <tt class="py-name">metavar</tt><tt class="py-op">=</tt><tt class="py-string">'p'</tt><tt class="py-op">,</tt> <tt class="py-name">type</tt><tt class="py-op">=</tt><tt id="link-36" class="py-name" targets="Function pypln.apps.extractor.directory()=pypln.apps.extractor-module.html#directory"><a title="pypln.apps.extractor.directory" class="py-name" href="#" onclick="return doclink('link-36', 'directory', 'link-36');">directory</a></tt><tt class="py-op">,</tt> <tt class="py-name">help</tt><tt class="py-op">=</tt><tt class="py-string">"Path of directory to scan for documents"</tt><tt class="py-op">)</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line"> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">    <tt class="py-name">args</tt> <tt class="py-op">=</tt> <tt id="link-37" class="py-name"><a title="pypln.apps.parser" class="py-name" href="#" onclick="return doclink('link-37', 'parser', 'link-30');">parser</a></tt><tt class="py-op">.</tt><tt class="py-name">parse_args</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line"> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">argv</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;</tt><tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">        <tt class="py-name">p</tt> <tt class="py-op">=</tt> <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">argv</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line">        <tt class="py-name">p</tt><tt class="py-op">=</tt> <tt class="py-string">"/home/flavio/Documentos/Reprints/"</tt> </tt>
<a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line"> </tt>
<a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line">    <tt id="link-38" class="py-name"><a title="pypln.pypln.sinks" class="py-name" href="#" onclick="return doclink('link-38', 'sinks', 'link-13');">sinks</a></tt> <tt class="py-op">=</tt> <tt id="link-39" class="py-name" targets="Function pypln.apps.extractor.setup_sink()=pypln.apps.extractor-module.html#setup_sink"><a title="pypln.apps.extractor.setup_sink" class="py-name" href="#" onclick="return doclink('link-39', 'setup_sink', 'link-39');">setup_sink</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line">    <tt id="link-40" class="py-name"><a title="pypln.pypln.workers" class="py-name" href="#" onclick="return doclink('link-40', 'workers', 'link-9');">workers</a></tt> <tt class="py-op">=</tt> <tt id="link-41" class="py-name" targets="Function pypln.apps.extractor.setup_workers()=pypln.apps.extractor-module.html#setup_workers"><a title="pypln.apps.extractor.setup_workers" class="py-name" href="#" onclick="return doclink('link-41', 'setup_workers', 'link-41');">setup_workers</a></tt><tt class="py-op">(</tt><tt class="py-number">8</tt><tt class="py-op">)</tt> </tt>
<a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line">    <tt id="link-42" class="py-name" targets="Function pypln.apps.extractor.extract()=pypln.apps.extractor-module.html#extract"><a title="pypln.apps.extractor.extract" class="py-name" href="#" onclick="return doclink('link-42', 'extract', 'link-42');">extract</a></tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">.</tt><tt class="py-name">path</tt><tt class="py-op">,</tt><tt class="py-number">8</tt><tt class="py-op">)</tt> </tt>
<a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/pypln">Project Homepage</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sat Mar 31 10:39:42 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
